<template>
  <div>

  </div>
</template>

<script>
export default {
  data () {
    return { }
  },
  methods: {
    passOrFailed (i) {
      return new Promise((resolve) => {
        // 异步操作
        setTimeout(() => {
          console.log(`${i}成功`)
          resolve()
        }, 1000)
      })
    },

    async test () {
      const arr = [1, 2, 3, 4, 5]
      for (const item of arr) {
        console.log(`${item}start`)
        await this.passOrFailed(item)
        console.log(`${item}end`)
      }
    }

  },

  mounted () {
    console.log('start!!!')
    this.test().then(() => { console.log('end!!!') })
  }
}
</script>

<style lang="less">
@import '~@/common/less/normal.less';

</style>
